UNPKG

create-nxtstart-app

Version:

Nxtstart is an easy to use, interactive CLI tool to bootstrap your next web-based project. The template is aimed at students to get an easy access to web development with example implementations. It is also useful for experts to speed up prototyping.

18 lines (14 loc) 708 B
'use server' import { redirect } from 'next/navigation' import { revalidatePath } from 'next/cache' /** * https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations */ // this is similiar to an API endpoint, it only runs on the server export default async function submit(date: number) { // could perform something like inserting data into database, even with authorization (see commented line below, can be used if next auth is used in this project) // const session = await getServerSession(authOptions) const id = date revalidatePath('/[locale]/serverActions', 'page') // revalidate cache if necessary redirect(`serverActions/${id}`) // Navigate to new route }